#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include "bill_dict.h"

typedef void (*fp_leaf)();

struct ber_handler_tree
{
  fp_leaf *leaves;
  struct ber_handler_tree *children;
};

void
leaf()
{
  printf("This is leaf function\n");
}

int
main(int argc, char *argv[])
{
  struct ber_handler_tree root, *l11, *l12, *l13, *l21, *l22, *l31, *l32, *l33, *node;
  root.children=malloc(sizeof(struct ber_handler_tree)*3);
  node=&root;
  
  l11=root.children; l12=root.children+1; l13=root.children+2;
  l11->children=malloc(sizeof(struct ber_handler_tree)*2);
  l21=l11->children; l22=l11->children+1;
  l21->children=malloc(sizeof(struct ber_handler_tree)*3);
  l31=l21->children; l32=l21->children+1; l33=l21->children+2;

  l31->leaves=malloc(sizeof(fp_leaf)); l32->leaves=malloc(sizeof(fp_leaf)*2);
  *(l31->leaves)=leaf; *(l32->leaves)=leaf; *(l32->leaves+1)=leaf;

  node=node->children;	// l11
  node=node->children;	// l21
  node=node->children;	// l31
  (node->leaves)[0]();

  return 0;
}
